<?php

namespace App\Repositories;

use App\Models\UserChannelChange;
use Cache;
class UserChannelChangeRepository extends Repository
{
    static $tag = 'testing.user.channel.change';

    public function getById($id)
    {
        $cacheKey = getCacheKey('testing.cache_key.testing_user_channel_change.info') . $id;
        $value = $this->remember($cacheKey, function () use ($id) {
            return UserChannelChange::where('id', $id)->first();
        });
        return $value;
    }

    public function store($data)
    {
        $this->clearCache($this->tag());
        $res = UserChannelChange::firstOrCreate($data);
        return $res;
    }

    public function cacheTime()
    {
        return config('testing.common_cache_time');
    }

    public function model()
    {
        return app(UserChannelChange::class);
    }

    public function tag()
    {
        return self::$tag;
    }
}